home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / MPW / gzip 1.2.2 / zforce.mac < prev    next >
Encoding:
Text File  |  1993-07-11  |  941 b   |  49 lines  |  [TEXT/MPS ]

  1. #
  2. # znew.mac -- znew for MPW
  3. #
  4. # written by Anthony C. Ard, 1993
  5. #
  6. # zforce: force a gz extension on all gzip files so that gzip will not
  7. # compress them twice.
  8. #
  9. # This can be useful for files with names truncated after a file transfer.
  10. # 12345678901234 is renamed to 12345678901.gz
  11.  
  12. set x "{0}"
  13. set exit 0
  14.  
  15. if {#} == 0
  16.     echo "force a ‘.gz’ extension on all gzip files"
  17.     echo "usage: {x} files…"
  18.     set exit 1;
  19.     exit 1;
  20. end
  21.  
  22. set res 0
  23.  
  24. for i in {Parameters}
  25.     if !`exists -f "{i}"`
  26.         echo "{x}: “{i}” not a file"
  27.         set res 1
  28.         continue
  29.     end
  30.     if "{i}" =~ /≈[.-]z∞/; continue; end
  31.     if "{i}" =~ /≈[.-]gz∞/; continue; end
  32.     if "{i}" =~ /≈[.]t[ag]z∞/; continue; end
  33.     
  34.     gzip -vl <"{i}" ≥Dev:Null | grep '^defl' >Dev:Null
  35.     if {Status} == 0
  36.         set new "{i}.gz"
  37.         rename "{i}" "{new}" ≥Dev:Null
  38.         if {Status} == 0
  39.             echo "{i} -- replaced with {new}"
  40.             continue
  41.         end
  42.         set res 1
  43.         echo "{x}: cannot rename {i} to {new}"
  44.     end
  45. end
  46.  
  47. set exit 1
  48. exit {res}
  49.